package com.cman777.springc.sample.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cman777.springc.common.bean.enums.StateEnum;
import com.cman777.springc.sample.bean.po.Idempotence;
import com.cman777.springc.sample.mapper.IdempotenceMapper;
import com.cman777.springc.sample.service.IdempotenceService;
import com.cman777.springc.mybatis.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author czc
 * @since 2020-09-15
 */
@Service
public class IdempotenceServiceImpl extends BaseServiceImpl< Idempotence,IdempotenceMapper> implements IdempotenceService {

    @Override
    public Idempotence selectByIdempotentceId(String key) {
        QueryWrapper<Idempotence> idempotenceQueryWrapper = new QueryWrapper<>();
        idempotenceQueryWrapper.eq("idempotence_id",key);
        return this.getOne(idempotenceQueryWrapper);
    }

    @Override
    public boolean deleteByIdempotentceId(String idempotenceId) {
        Map<String,Object> whereMap = new LinkedHashMap<>();
        whereMap.put("idempotence_id",idempotenceId);
        return this.removeByMap(whereMap);
    }
}
